package com.fa.controller;

import com.fa.common.core.controller.BaseController;
import com.fa.common.core.domain.AjaxResult;
import com.fa.common.core.page.TableDataInfo;
import com.fa.domain.Area;
import com.fa.domain.AreaSearchVO;
import com.fa.domain.AreaVO;
import com.fa.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/wm/area")
public class AreaController extends BaseController {
    @Autowired
    private AreaService areaService;

    @GetMapping("/list")
    public TableDataInfo listArea(AreaSearchVO areaSearchVO){
        startPage();
        List<AreaVO> areaVOS = areaService.listArea(areaSearchVO);
        return getDataTable(areaVOS);
    }

    @GetMapping("/listById")
    public AjaxResult listAreaById(Long areaId){
        AreaVO areaVO = areaService.listAreaById(areaId);
        return success(areaVO);
    }

    @GetMapping("/del")
    public AjaxResult listAreaById(List<Long> areaIds){
        areaService.delArea(areaIds);
        return success();
    }

    @PostMapping("/update")
    public AjaxResult updateArea(@RequestBody Area area){
        areaService.updateArea(area);
        return success();
    }
}
